package pub.wkq.thread;

import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.stream.IntStream;

/**
 * @author 王开琦
 */
public class QuttingCompletable {
    public static void main(String[] args) {
        List<QuittableTask> tasks = IntStream.range(1, QuittableTasks.COUNT).mapToObj(QuittableTask::new).toList();
        List<CompletableFuture<Void>> completableFutures = tasks.stream().map(CompletableFuture::runAsync).toList();
        new Nap(1);
        tasks.forEach(QuittableTask::quit);
        completableFutures.forEach(CompletableFuture::join);
    }
}
